package org.linlinjava.litemall.admin.web2.goods.resp;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.linlinjava.litemall.core.util.Util;
import org.linlinjava.litemall.db.domain.TGoods;

import java.time.format.DateTimeFormatter;

@ApiModel
public class GResp4 {

    @ApiModelProperty("id")
    private Integer id;
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("图片")
    private String img;
    @ApiModelProperty("几人团")
    private Integer groupNumber;
    @ApiModelProperty("分类")
    private String catalog;
    @ApiModelProperty("限购数目")
    private Integer personLimit;
    @ApiModelProperty("是否只限新人购买")
    private Boolean newPerson;
    @ApiModelProperty("折扣")
    private Double discount;
    @ApiModelProperty("当前价")
    private Double currentPrice;
    @ApiModelProperty("销售价")
    private Double salePrice;
    @ApiModelProperty("成本价")
    private Double costPrice;
    @ApiModelProperty("佣金")
    private Integer commission;
    @ApiModelProperty("活动库存")
    private Integer activityStock;
    @ApiModelProperty("拼团初始销量")
    private Integer initSaleCount;
    @ApiModelProperty("活动时间")
    private String activityDate;

    @ApiModelProperty("活动时间开始")
    private String activityBegin;
    @ApiModelProperty("活动时间结束")
    private String activityEnd;

    public GResp4(TGoods goods) {
        this.id = goods.getId();
        this.name = goods.getMainTitle();
        costPrice = goods.getCostPrice().doubleValue();
        currentPrice = goods.getCurrentPrice().doubleValue();
        salePrice = goods.getSalePrice().doubleValue();

        activityStock = goods.getDailyLimit();
        commission = goods.getCommission();
        groupNumber = goods.getGroupNumber();
        personLimit = goods.getPersonLimit();
        newPerson = goods.getIsNew();
        commission = goods.getCommission();
        initSaleCount = 22;
        img = goods.getMainPic();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        activityBegin = goods.getActivityBegin().format(formatter);
        activityEnd = goods.getActivityEnd().format(formatter);
        activityDate =activityBegin + "至" + activityEnd;
        this.discount = Util.retain2(currentPrice / salePrice);

    }

    public GResp4() {
    }


    public String getActivityDate() {
        return activityDate;
    }

    public void setActivityDate(String activityDate) {
        this.activityDate = activityDate;
    }

    public Integer getGroupNumber() {
        return groupNumber;
    }

    public void setGroupNumber(Integer groupNumber) {
        this.groupNumber = groupNumber;
    }

    public Integer getPersonLimit() {
        return personLimit;
    }

    public void setPersonLimit(Integer personLimit) {
        this.personLimit = personLimit;
    }


    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public Boolean getNewPerson() {
        return newPerson;
    }

    public void setNewPerson(Boolean newPerson) {
        this.newPerson = newPerson;
    }

    public Integer getInitSaleCount() {
        return initSaleCount;
    }

    public void setInitSaleCount(Integer initSaleCount) {
        this.initSaleCount = initSaleCount;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public String getCatalog() {
        return catalog;
    }

    public void setCatalog(String catalog) {
        this.catalog = catalog;
    }

    public Double getDiscount() {
        return discount;
    }

    public void setDiscount(Double discount) {
        this.discount = discount;
    }

    public Double getCurrentPrice() {
        return currentPrice;
    }

    public void setCurrentPrice(Double currentPrice) {
        this.currentPrice = currentPrice;
    }

    public Double getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(Double salePrice) {
        this.salePrice = salePrice;
    }

    public Double getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(Double costPrice) {
        this.costPrice = costPrice;
    }

    public Integer getCommission() {
        return commission;
    }

    public void setCommission(Integer commission) {
        this.commission = commission;
    }

    public Integer getActivityStock() {
        return activityStock;
    }

    public void setActivityStock(Integer activityStock) {
        this.activityStock = activityStock;
    }

    public String getActivityBegin() {
        return activityBegin;
    }

    public void setActivityBegin(String activityBegin) {
        this.activityBegin = activityBegin;
    }

    public String getActivityEnd() {
        return activityEnd;
    }

    public void setActivityEnd(String activityEnd) {
        this.activityEnd = activityEnd;
    }
}
